<include file="public@header" />
<style>
    p{
       margin:0;
       padding:0;
    }
    .label{
        display:inline-block;
        margin-bottom:5px;
        padding:5px 10px;
        border-radius:50px;
    }
    .imgtip{
        margin-bottom:5px;
    }
</style>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a >实名认证列表</a></li>
		</ul>
        
        <form class="well form-inline margin-top-20" method="post" action="{:url('Auth/index')}">
            状态：
            <select class="form-control" name="status" style="width: 100px;">
                <option value=''>全部</option>
                <volist name="status" id="v">
                    <option value="{$key}" <if condition="input('request.status') neq '' && input('request.status') eq $key">selected</if>>{$v}</option>
                </volist>
            </select>
            提交时间：
            <input class="form-control js-bootstrap-date" name="start_time" id="start_time" value="{:input('request.start_time')}" aria-invalid="false" style="width: 110px;"> - 
            <input class="form-control js-bootstrap-date" name="end_time" id="end_time" value="{:input('request.end_time')}" aria-invalid="false" style="width: 110px;">
            用户ID：
            <input class="form-control" type="text" name="uid" style="width: 200px;" value="{:input('request.uid')}"
                   placeholder="用户ID">
            关键词：
            <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
                   placeholder="姓名、电话">
            <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('Auth/index')}">清空</a>
        </form>
    
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>用户</th>
						<th>姓名</th>
						<th>电话</th>
						<th>身份证号</th>
                        <th>状态</th>
						<th width="10%">审核意见</th>
						
						<th>提交时间</th>
						<th>处理时间</th>
						<th align="center">{:lang('ACTIONS')}</th>
					</tr>
				</thead>
				<tbody>
					<foreach name="list" item="vo">
					<tr>
						<td>{$vo['userinfo']['user_nickname']} ( {$vo['uid']} )</td>	
						<td>{$vo['name']}</td>
						<td>{$vo['mobile']}</td>
						<td>{$vo['cardno']}</td>
                        <td>{$status[$vo['status']]}</td>
						<td>{$vo['reason']}</td>
						
                        <td>{:date('Y-m-d H:i',$vo['addtime'])}</td>
                        <td>{:date('Y-m-d H:i',$vo['uptime'])}</td>
						<td>
                            <if condition="$vo['status'] eq 0">
                                <a class="btn btn-xs btn-success setstatus" data-uid="{$vo['uid']}" data-status="1">同意</a>
                                <a class="btn btn-xs btn-danger setstatus" data-uid="{$vo['uid']}" data-status="2">拒绝</a>
                            </if>
                            
                            <if condition="$vo['status'] eq 1">
                                <a class="btn btn-xs btn-danger setstatus" data-uid="{$vo['uid']}" data-status="2">拒绝</a>
                            </if>
                            
                            <if condition="$vo['status'] eq 2">
                                <a class="btn btn-xs btn-success setstatus" data-uid="{$vo['uid']}" data-status="1">同意</a>
                            </if>

                            <!-- <a class="btn btn-xs btn-primary" href='{:url("admin/Auth/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a> -->
						</td>
					</tr>
					</foreach>
				</tbody>
			</table>
			<div class="pagination">{$page}</div>

		</form>
	</div>
    <div id="enlarge_images" style="position:fixed;display:none;z-index:2;"></div>
	<script src="__STATIC__/js/admin.js"></script>
    <script>
        $(function(){
            var ei=$('#enlarge_images');
            var imgtip=$('.imgtip');
            
            imgtip.mousemove(function(event){
                event = event || window.event;
                
                var html = '<img src="' + this.src + '" style="max-width:500px;max-height:500px;"/>';
                
                ei.html(html);
                var top  = document.body.scrollTop + event.clientY + 10 + "px";
                var left = document.body.scrollLeft + event.clientX + 10 + "px";
            
                var css={
                    'display':'block',
                    'top':top,
                    'left':left,
                }
                ei.css(css);
            })
            
            imgtip.mouseout(function(){
                ei.html('');                
                var css={
                    'display':'none',
                }
                ei.css(css);
            })
            imgtip.click(function(){
                ei.html('');                
                var css={
                    'display':'none',
                }
                ei.css(css);
                window.open( this.src );
            })
            Wind.use('layer');
            $('.setstatus').click(function(){
                var _this=$(this);
                var uid=_this.data('uid');
                var status=_this.data('status');
                var value=' ';
                layer.prompt({
                    formType: 2,
                    title: '审核意见',
                    value: value,
                    area: ['800px', '100px'] //自定义文本域宽高
                }, function(value, index, elem){
					if(status==2){
						value=value.trim();
						if(value=='' || !value){
							layer.msg("请填写审核意见");
							return !1;
						}
					}
					
                    $.ajax({
                        url:"{:url('Auth/setstatus')}",
                        type:'POST',
                        data:{uid:uid,status:status,reason:value},
                        dataType:'json',
                        success:function(data){
                            var code=data.code;
                            if(code==0){
                                layer.msg(data.msg);
                                return !1;
                            }
                            layer.msg(data.msg,{},function(){
                                layer.closeAll();
                                reloadPage(window);
                            });
                            
                        },
                        error:function(){
                            layer.msg('操作失败，请重试')
                        }
                    });
                    
                });
                
            })
        })
    </script>
</body>
</html>